package vns.server.domain;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import vns.shared.RuleActionDTO;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class RuleAction {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;
	@Persistent
	private String actionType;
	@Persistent
	private String value;

	public RuleAction(RuleActionDTO ruleActionDTO) {
		this.actionType = ruleActionDTO.getActionType();
		this.value = ruleActionDTO.getValue();
	}

	public void updateFromDTO(RuleActionDTO ruleActionDTO) {
		this.actionType = ruleActionDTO.getActionType();
		this.value = ruleActionDTO.getValue();
	}

	public RuleActionDTO toDTO() {
		RuleActionDTO ruleActionDTO = new RuleActionDTO(this.id,
				this.actionType, this.value);
		return ruleActionDTO;
	}

	public Key getid() {
		return id;
	}

	public void setActionType(String actionType) {
		this.actionType = actionType;
	}

	public String getActionType() {
		return actionType;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getValue() {
		return value;
	}

}
